import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { DeviceWarningForm, DeviceWarningQuery, DeviceWarningVO } from './types';

/**
 * 查询预警信息列表
 * @param query
 * @returns {*}
 */

export const listDeviceWarning = (query?: DeviceWarningQuery): AxiosPromise<DeviceWarningVO[]> => {
  return request({
    url: '/iot/deviceWarning/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询预警信息详细
 * @param warningId
 */
export const getDeviceWarning = (warningId: string | number): AxiosPromise<DeviceWarningVO> => {
  return request({
    url: '/iot/deviceWarning/' + warningId,
    method: 'get'
  });
};

/**
 * 新增预警信息
 * @param data
 */
export const addDeviceWarning = (data: DeviceWarningForm) => {
  return request({
    url: '/iot/deviceWarning',
    method: 'post',
    data: data
  });
};

/**
 * 修改预警信息
 * @param data
 */
export const updateDeviceWarning = (data: DeviceWarningForm) => {
  return request({
    url: '/iot/deviceWarning',
    method: 'put',
    data: data
  });
};

/**
 * 删除预警信息
 * @param warningId
 */
export const delDeviceWarning = (warningId: string | number | Array<string | number>) => {
  return request({
    url: '/iot/deviceWarning/' + warningId,
    method: 'delete'
  });
};
